<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<%@ taglib uri="http://www.springframework.org/tags/form" prefix="springForm" %>
<%@ taglib uri="http://www.springframework.org/tags" prefix="spring"%>

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>BANK | FIXED DEPOSIT</title>
<script type='text/javascript' src='/bank/dwr/interface/bank.js'></script>
<script type='text/javascript' src='/bank/dwr/engine.js'></script>
<script type='text/javascript' src='/bank/dwr/util.js'></script>
<script type="text/javascript">

function showAllAccounts(){
	alert ("In show All Accounts Method.");
	bank.getAccounts(callbackMethod);
}

function callbackMethod(data){
	alert("Length of records: "+data[0].accountId);
	
}
</script>
</head>

<body>
<h3>Fixed Deposit</h3>
	<springForm:form commandName="fixdeposit" action="fixdeposit.bank?action=saveFixDeposit">
	<table>
	<tr>
		<td>Fix Deposit Id : </td>
		<td><springForm:input path="fixDepositId"/></td>
	</tr>
	
	<tr>
		<td> Account Id : </td>
		<td><springForm:select path="accountId" >
			<springForm:options items="${fixdeposit.accountIds}" />
		</springForm:select>			
		</td>		
	</tr>
	<c:forEach items="${ fixdeposit.accountIds }" var="account">
		<c:out value="${account} " />
	</c:forEach>
	<tr>
		<td>Name : </td>
		<td><springForm:input path="accountHolderName" /></td>
	</tr>
	<tr>
		<td>Bank : </td>
		<td><springForm:input path="bankName" /></td>
	</tr>
	<tr>
		<td>Start Date : </td>
		<td> <spring:bind path="startDate">
			<input type="text" name="<c:out value='${status.expression }'/>" 
							value="<fmt:formatDate value='${status.value}' pattern='dd/MM/yyyy'/>"/>
			</spring:bind> </td>
	</tr>
	<tr>
		<td>Meturity Date : </td>
		<td><spring:bind path="meturityDate">
			<input type="text" name="<c:out value='${status.expression }'/>" 
							value="<fmt:formatDate value='${status.value}' pattern='dd/MM/yyyy'/>"/>
			</spring:bind></td>
	</tr>
	<tr>
		<td>Amount : </td>
		<td><springForm:input path="amount"/></td>
	</tr>
	<tr>
		<td>Status : </td>
		<td><springForm:input path="status"/></td>
	</tr>
	<tr>
		<td colspan="2"><input type="submit" name="submit" value="Submit" /></td>
	</tr>
	</table>
	<input type="button" name="allaccounts" value="all Accounts" onclick="showAllAccounts()"/>
	</springForm:form>
	<table>
	<tbody id="demo">
	</tbody>
	</table>
</body>
</html>